import { Table, TablePaginationConfig } from 'antd'
import { ITable } from './types'
import styles from './table.module.less'
import { useEffect, useState } from 'react';
export default function StandardTable(props: ITable) {
    const {
        loading,
        pagination,
        rowSelection,
        scroll,
        rowId,
        changeFilter
    } = props;

    let [data,setData]= useState<Array<object>>([]);
    let [header,setHeader] = useState<Array<object>>([]);

    useEffect(()=>{
        setData(props.tableData)
    },[props.tableData])

    useEffect(()=>{
        setData(props.tableHead)
    },[props.tableHead]);

    return (
        <div className={styles.table_wrapper}>
            <Table
                columns={header}
                dataSource={data}
                loading={loading}
                pagination={pagination}
                rowSelection={rowSelection}
                rowKey={rowId}
                bordered
                scroll={scroll}
                onChange={(val) => changeFilter(val)}
            ></Table>
        </div>
    )
}
